home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 25
/
Mac Magazin and MacEasy Magazine CD - Issue 25.iso
/
Grafik & Text
/
Alpha
/
Tcl
/
SystemCode
/
pasteWordUnderMouse.tcl
< prev
next >
Wrap
Text File
|
1996-08-15
|
3KB
|
117 lines
# **************************************************************
#
# Filename : pasteWordUnderMouse.tcl
#
# Author : HjK
#
# Creation Date: 11.03.1995 {14:06:59 Uhr}
# Last update: 24.04.1995 {11:25:53 Uhr}
#
# System : Alpha Version 6.0b13, Mar. 25, 1995
#
# Copyright: Juergen Krey, 11.03.1995
#
# MAIL: Bergstr. 38, 53783 Eitorf
# E-mail: krey@gmd.de
#
# **************************************************************
# Trying to program pasteWordUnderMouse
# matchIt doesnt work correct for () and [] at some positions
# therefore use balance, if appropriate
# There are four possible Delimiter matches
# • openingDelim right of mouse-pointed position
# • openingDelim left of mouse-pointed position
# • closingDelim right of mouse-pointed position
# • closingDelim left of mouse-pointed position
# ... they are treated in the enumerated order!
proc pasteWordUnderMouse { {insertWhitespace 0} } {
set res [catch {mousePos} mousePos]
if {$res != 0} { return }
set oldCursorPos [getPos]
set bufferPos [eval rowColToPos $mousePos]
goto $bufferPos
set nextPos [expr $bufferPos + 1]
set nextChar [getText $bufferPos $nextPos]
set prevPos [expr $bufferPos - 1]
set prevChar [getText $prevPos $bufferPos]
set closingDelims "\x29\x5d\x7d"
set openingDelims "\x28\x5b\x7b"
# • openingDelim right of mouse-pointed position
if {[string first $nextChar $openingDelims] != -1} {
goto $nextPos
set balanceFailed [catch {balance}]
if {! $balanceFailed} {
set res [getSelect]
goto $oldCursorPos
insertText $res
return
}
}
# • openingDelim left of mouse-pointed position
if {[string first $prevChar $openingDelims] != -1} {
set balanceFailed [catch {balance}]
if {! $balanceFailed} {
set res [getSelect]
goto $oldCursorPos
insertText $res
return
}
}
# • closingDelim right of mouse-pointed position
if {[string first $nextChar $closingDelims] != -1} {
set balanceFailed [catch {balance}]
if {! $balanceFailed} {
set res [getSelect]
goto $oldCursorPos
insertText $res
return
}
}
# • closingDelim left of mouse-pointed position
if {[string first $nextChar $closingDelims] != -1} {
goto $prevPos
set balanceFailed [catch {balance}]
if {! $balanceFailed} {
set res [getSelect]
goto $oldCursorPos
insertText $res
return
}
}
# • normal insertion of a wordBreak-Pattern string
backwardWord
set from [getPos]
forwardWord
set to [getPos]
set res [getText $from $to]
goto $oldCursorPos
switch $insertWhitespace {
0 {set res " $res "}
1 {}
2 {append res .}
default {}
}
insertText $res
}
#endproc pasteWordUnderMouse
##############################################################################
bind F10 <s> {pasteWordUnderMouse 0}
bind F10 {pasteWordUnderMouse 1}
bind F10 <z> {pasteWordUnderMouse 2}
# **************************************************EOF